home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 7.9 KB | 220 lines | [TEXT/ttxt] |
- --<<<-
- -- Filename:
- -- mapdoc.sx
-
- -- Other Files Required:
- -- mapwin.sx
-
- -- Purpose:
- -- Class definition for the MapDocument class.
-
- -- Specialized Classes:
- -- MapDocument
-
- -- Instructions to User:
- -- Class MapDocument is a ScriptX Document for displaying objects which
- -- have a bitmap image, text description and map detail. It consists of two
- -- pages, a front page and a map detail page. When the target object of the
- -- document changes, the page elements of these pages are automatically updated.
-
- -- Author:
- -- Steve Mayer, Felicia Santelli
-
- in module Autofinder
-
- class MapDocument (Document)
- end
-
- -- Method init adds all of the pages to the document.
- method init self {class MapDocument} #rest args #key media: ->
- (
- apply nextMethod self args
- addFrontPage self media
- addMapPage self media
- addNotesPage self media
- return self
- )
-
- -- Method addFrontPage adds the front page to the document. The front page consists
- -- of one page layer, which contains page elements for the image and text, and
- -- buttons for navigation. The image page element is an instance of
- -- TwoDShape, which presents a graphic repreentation of the document's
- -- target object. The text page element is a TextPresenter, which presents a text
- -- description of the document's target object.
- method addFrontPage self {class MapDocument} media ->
- (
- -- Create a page layer for the first page of the document.
- local frontLayer := new PageLayer boundary:(new Rect x2:365 y2:274)
-
- -- Add buttons for map detail, notes, and printing.
- local ac := new ActuatorController space:frontLayer wholeSpace:true
- local mapButton := new PushButton pressedPresenter:media["Map Button"] \
- releasedPresenter:(new twodshape boundary:media["Map Button"].boundary)
- mapButton.x := 4; mapButton.y := 10
- mapButton.activateAction := (authorData button -> goto self 2)
- prepend frontLayer mapButton
-
- local notesButton := new PushButton pressedPresenter:media["Notes Button"] \
- releasedPresenter:(new twodshape boundary:media["Notes Button"].boundary)
- notesButton.x := 4; notesButton.y := 100
- notesButton.activateAction := (authorData button -> goto self 3)
- prepend frontLayer notesButton
-
- local printButton := new PushButton pressedPresenter:media["Print Button"] \
- releasedPresenter:(new twodshape boundary:media["Print Button"].boundary)
- printButton.x := 4; printButton.y := 190
- printButton.activateAction := (authorData button -> printWindow self.presentedBy)
- prepend frontLayer printButton
-
- -- Create a page element for the image and add it to the page layer.
- local imageElement := new PageElement \
- presenter:(new TwoDShape boundary:(new Rect x2:200 y2:163)) \
- target:(e ->
- (
- local current := getParentData e Document
- return current.adPic
- ))
- translate imageElement.transform 120 10
- prepend frontLayer imageElement
-
- -- Create a bounding box for the text and add it to the page layer.
- local boxBrush := new Brush color:blackColor
- boxBrush.lineWidth := 2
- local textBoundary := new TwoDShape boundary:(new Rect x2:200 y2:84) stroke:boxBrush
- translate textBoundary.transform 120 180
- prepend frontLayer textBoundary
-
- -- Create a page element for the text and add it to the page layer.
- local t := new TextPresenter boundary:(new Rect x2:190 y2:83) target:("" as Text) \
- brush:blackBrush
- setDefaultAttr t @font (new PlatformFont name:"Palatino")
- setDefaultAttr t @leading 12
- setDefaultAttr t @size 12
-
- local textElement := new PageElement presenter:t \
- target:(e ->
- (
- local current := getParentData e Document
- return current.adText
- ))
- translate textElement.transform 123 181
- prepend frontLayer textElement
-
- -- Create a new page with the image/text layer and add it to the document.
- local frontPage := new Page boundary:frontLayer.boundary frame:frontLayer
- append self frontPage
- )
-
- -- The map detail page consists of one page layer, which contains a page element for
- -- the map detail image and a push button for returning to the front page.
- method addMapPage self {class MapDocument} media ->
- (
- -- Create a page layer for the detail map page of the document.
- local mapLayer := new PageLayer boundary:(new Rect x2:365 y2:274)
-
- -- Add buttons for map detail, notes, and printing.
- local ac := new ActuatorController space:mapLayer wholeSpace:true
- local carButton := new PushButton pressedPresenter:media["Car Button"] \
- releasedPresenter:(new twodshape boundary:media["Car Button"].boundary)
- carButton.x := 4; carButton.y := 30
- carButton.activateAction := (authorData button -> goto self 1)
- prepend mapLayer carButton
-
- local notesButton := new PushButton pressedPresenter:media["Notes Button"] \
- releasedPresenter:(new twodshape boundary:media["Notes Button"].boundary)
- notesButton.x := 4; notesButton.y := 100
- notesButton.activateAction := (authorData button -> goto self 3)
- prepend mapLayer notesButton
-
- local printButton := new PushButton pressedPresenter:media["Print Button"] \
- releasedPresenter:(new twodshape boundary:media["Print Button"].boundary)
- printButton.x := 4; printButton.y := 190
- printButton.activateAction := (authorData button -> printWindow self.presentedBy)
- prepend mapLayer printButton
-
- -- Create a page element for the map and add it to the page layer.
- local mapElement := new PageElement \
- presenter:(new CostumedPresenter boundary:(new Rect x2:288 y2:274)) \
- target:(e ->
- (
- local current := getParentData e Document
- current.mapPresenter.x := -1
- current.mapPresenter.y := -1
- return current.mapPresenter
- ))
-
- translate mapElement.transform 79 1
- append mapLayer mapElement
-
- -- Create a new page with the map layer and add it to the document.
- local mapPage := new Page boundary:mapLayer.boundary frame:mapLayer
- append self mapPage
- )
-
- -- The notes detail page consists of one page layer, which contains a page element for
- -- the notes and a push button for returning to the front page.
- method addNotesPage self {class MapDocument} media ->
- (
- -- Create a page layer for the notes page of the document.
- local notesLayer := new PageLayer boundary:(new Rect x2:365 y2:274)
-
- -- Add buttons for map detail, notes, and printing.
- local ac := new ActuatorController space:notesLayer wholeSpace:true
- local carButton := new PushButton pressedPresenter:media["Car Button"] \
- releasedPresenter:(new twodshape boundary:media["Car Button"].boundary)
- carButton.x := 4; carButton.y := 30
- carButton.activateAction := (authorData button -> goto self 1)
- prepend notesLayer carButton
-
- local mapButton := new PushButton pressedPresenter:media["Map Button"] \
- releasedPresenter:(new twodshape boundary:media["Map Button"].boundary)
- mapButton.x := 4; mapButton.y := 100
- mapButton.activateAction := (authorData button -> goto self 2)
- prepend notesLayer mapButton
-
- local printButton := new PushButton pressedPresenter:media["Print Button"] \
- releasedPresenter:(new twodshape boundary:media["Print Button"].boundary)
- printButton.x := 4; printButton.y := 190
- printButton.activateAction := (authorData button -> printWindow self.presentedBy)
- prepend notesLayer printButton
-
- -- Create a page element for the notes and add it to the page layer.
- local notesEditer := new textEdit boundary:(new Rect x2:285 y2:270) \
- target:(new text string:"") stroke:blackbrush
- local notesElement := new PageElement \
- presenter:notesEditer boundary:notesEditer.boundary \
- target:(e ->
- (
- local current := getParentData e Document
- return current.adNotes
- ))
-
- translate notesElement.transform 79 3
- append notesLayer notesElement
-
- -- Create a new page with the notes layer and add it to the document.
- local notesPage := new Page boundary:notesLayer.boundary frame:notesLayer
- append self notesPage
- )
-
- method changePage self {class MapDocument} pg ->
- (
- local prev := self.data
-
- nextMethod self pg
- makePurgeable prev.adPic
- makePurgeable prev.mapPresenter
- )
-
- method leaveScene self {class MapDocument} ->
- (
- local item := self.data
-
- emptyout self
- makePurgeable item.adPic
- makePurgeable item.mapPresenter
- )
-
- -->>>
- "Compiled mapdoc.sx"
-